//
//  UIBarButtonItem+Extension.swift
//  SinaWeiBo
//
//  Created by immncjykeny on 2017/4/25.
//  Copyright © 2017年 immncjykeny. All rights reserved.
//

import UIKit
extension UIBarButtonItem{
    //便利构造函数
    
    /// 
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: fontSzie = 16
    ///   - action: selector
    ///   - target:anyobject
    convenience init(title:String,fontSize:CGFloat = 16,action:Selector,target:AnyObject,isBack:Bool = false) {
        let btn:UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named:imageName), for: .normal)
            btn.setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        btn.addTarget(target, action: action, for: .touchUpInside)
        self.init(customView: btn)
    }
}
